//#include<stdio.h>
//#include<stdbool.h>
//#include<assert.h>
//typedef struct 
//{
//	int* p;
//	int head;
//	int tail;
//	int num;
//} MyCircularQueue;
//
//
//MyCircularQueue* myCircularQueueCreate(int k) 
//{
//	MyCircularQueue* tmp = (MyCircularQueue*)malloc(sizeof(MyCircularQueue));
//	assert(tmp);
//	tmp->p = (int*)malloc(sizeof(int)*(k+1));
//	tmp->head = tmp->tail = 0;
//	tmp->num =k ;
//	return tmp;
//}
//
//bool myCircularQueueEnQueue(MyCircularQueue* obj, int value) 
//{
//	if ((obj->tail + 1) % (obj->num + 1) == obj->head)
//	{
//		return false;
//	}
//	else
//	{
//		obj->p[obj->tail] = value;
//		obj->tail = (obj->tail + 1) % (obj->num + 1);
//		return true;
//	}
//}
//
//bool myCircularQueueDeQueue(MyCircularQueue* obj) 
//{
//	if (obj->head==obj->tail)
//	{
//		return false;
//	}
//	else
//	{
//		int a = obj->head;
//		obj->head = (a + 1) % (obj->num + 1);
//		return true;
//	}
//
//
//}
//
//int myCircularQueueFront(MyCircularQueue* obj) {
//	if (obj->head != obj->tail)
//		return obj->p[obj->head];
//	else
//		return 0;
//}
//
//int myCircularQueueRear(MyCircularQueue* obj) {
//	if (obj->head != obj->tail)
//	{
//		int a = (obj->tail + obj->num) % (obj->num + 1);
//		return obj->p[a];
//	}
//	else
//		return -1;
//}
//
//bool myCircularQueueIsEmpty(MyCircularQueue* obj) 
//{
//	if (obj->head == obj->tail)
//	{
//		return true;
//	}
//	else
//		return false;
//}
//
//bool myCircularQueueIsFull(MyCircularQueue* obj) 
//{
//	if ((obj->tail + 1) % (obj->num + 1) == obj->head)
//	{
//		return true;
//	}
//	else
//		return false;
//}
//
//void myCircularQueueFree(MyCircularQueue* obj) 
//{
//	free(obj->p);
//	obj->head = obj->tail = obj->num = 0;
//}
#include<stdio.h>
#include<assert.h>
#include<stdbool.h>
#include<stdlib.h>
typedef int definetype;
typedef struct node
{
    definetype a;
    struct node* next;
}Node;
typedef struct 
{
    Node* front;
    Node* prere;
    Node* rear;
    int num;
} MyCircularQueue;


MyCircularQueue* myCircularQueueCreate(int k) 
{
    MyCircularQueue* tmp = (MyCircularQueue*)malloc(sizeof(MyCircularQueue));
    assert(tmp);
    int i = 0;
    Node*c=NULL, *d=NULL;
    while (i!=(k+1))
    {
       
        if (i == 0)
        {
            c = (Node*)malloc(sizeof(Node));
            assert(c);
            c->next = NULL;
            tmp->front = tmp->rear=tmp->prere = c;
            i++;
        }
        else
        {
            d = (Node*)malloc(sizeof(Node));
            c->next = d;
            c = d;
            i++;
            if (i == k+1)
            {
                c->next = tmp->front;
            }
        }
       
    }
    tmp->num = k;
    return tmp;
}
bool myCircularQueueEnQueue(MyCircularQueue* obj, int value) {
    if (obj->rear->next == obj->front)
    {
        return false;
    }
    else
    {
        definetype*we=&obj->rear->a ;
        *we = value;
        obj->prere = obj->rear;
        obj->rear = obj->rear->next;
        return true;
    }
}
bool myCircularQueueDeQueue(MyCircularQueue* obj) {
    if (obj->front == obj->rear)
    {
        return false;
    }
    else
    {
       
        obj->front = obj->front->next;
        return true;
    }
}
int myCircularQueueFront(MyCircularQueue* obj) {
    if (obj->front == obj->rear)
        return -1;
    else
    return (obj->front)->a;
}
int myCircularQueueRear(MyCircularQueue* obj) {
    if (obj->front == obj->rear)
        return -1;
    else
    return (obj->prere)->a;
}
bool myCircularQueueIsEmpty(MyCircularQueue* obj) {
    if (obj->front == obj->rear)
    {
        return true;
    }
    else
        return false;
}
bool myCircularQueueIsFull(MyCircularQueue* obj) {
    if (obj->rear->next == obj->front)
    {
        return true;
    }
    else
        return false;
}
void myCircularQueueFree(MyCircularQueue* obj) 
{
    Node* tmp = NULL;
    while (obj->num!=-1)
    {
        tmp= obj->front->next;
        free(obj->front);
        obj->front = tmp;
        obj->num--;
    }
    obj->front = obj->rear = obj->prere = NULL;
    obj->num = 0;
    free(obj);
}

int main()
{
    MyCircularQueue* A;
    A=myCircularQueueCreate(3);
    myCircularQueueEnQueue(A,1);
    myCircularQueueEnQueue(A, 18);
    myCircularQueueEnQueue(A, 1181);
    myCircularQueueDeQueue(A);
    myCircularQueueDeQueue(A);
    myCircularQueueEnQueue(A, 119651);
   
    printf("%d ",myCircularQueueFront(A));
    printf("%d ", myCircularQueueRear(A));
    return 0;
}